package com.music.wangyi.ui.fragment

import android.os.Bundle
import android.os.CountDownTimer
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.music.wangyi.Base.BaseFragment
import com.music.wangyi.R
import kotlinx.android.synthetic.main.activity_main.*

class SplashFragment : BaseFragment() {

    val countDownTimer by lazy { object : CountDownTimer(3000,1000) {
            override fun onFinish() {
                navigatePopUpTo(R.id.loginFragment,R.id.splashFragment)
            }

            override fun onTick(millisUntilFinished: Long) {
            }

        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_splash,container,false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        countDownTimer.start()
    }

    override fun onDestroyView() {
        super.onDestroyView()
        countDownTimer.cancel()
        Log.w("tag","取消countDownTimer")
    }
}
